package com.bancomer.pig.functions;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class PigUtils {
	
	
	static Boolean compareDate(String date1, String date2,String eval, String format){
		
		
		
		SimpleDateFormat  dateOneString = new SimpleDateFormat(format);
		
		
		
		try {
			
			Date dateOne= dateOneString.parse(date1);
			
			Date dateTwo= dateOneString.parse(date2);
			
			
			
			
			
			if(eval.contains(">=")){
				
				return dateOne.getTime() >= dateTwo.getTime();
				
			}else if(eval.contains("<=")){
				
				return dateOne.getTime() <= dateTwo.getTime();
				
			}else if(eval.contains("<")){
				
				return dateOne.getTime() < dateTwo.getTime();
				
			}else if(eval.contains(">")){
				
				return dateOne.getTime() > dateTwo.getTime();
				
			}else if(eval.contains("==")){
				
				return dateOne.getTime() == dateTwo.getTime();
				
			}
				
			
			
			
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
		
		
		
		return false;
	}
	

}
